package duoxiancheng;

/**
 * 共享资源 并发
 */
public class web12306 implements Runnable{
    private int ticket = 99;

    @Override
    public void run() {
        while (true){
            if (ticket<0){
                break;
            }
            try {//模拟网络延迟，高并发
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println( Thread.currentThread().getName()+"---->"+ticket--);
        }
    }

    public static void main(String[] args) {
        //一份资源
        web12306 w06= new web12306();
        //多个代理
        new Thread(w06,"问问").start();
        new Thread(w06,"大幅度").start();
        new Thread(w06,"天天").start();
    }
}
